package com.itheima.io.bufferedwriter.demo02;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * BufferedWriter中的特有功能
 * public void newLine()写一行行分隔符，行分隔符字符串由系统属性定义
 */
public class BufferedWriterDemo01 {

    public static void main(String[] args) throws IOException {

        // 1. 创建BufferedWriter对象
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("itheima-io-bufferedwriter\\b.txt"));

        // 2. 调用方法写数据
        for(int x = 0 ; x < 10 ; x++) {
            bufferedWriter.write("hello" + x);
            // bufferedWriter.write("\r\n");
            bufferedWriter.newLine();     // 这个方法做了平台的兼容性，根据指定的平台去写入指定的换行符
            bufferedWriter.flush();
        }

        // 3. 释放资源
        bufferedWriter.close();

    }

}
